<!--
 * @Author       : xiaoxiaoguai
 * @Date         : 2025-05-20 16:42:12
 * @LastEditors  : 
 * @LastEditTime : 2025-08-05 09:23:41
 * @Description  : 
-->
<template>
	<!-- <uv-navbar :fixed="false" title="确认退出登录" left-arrow @leftClick="$onClickLeft" /> -->
	<uv-modal ref="modal" width="600rpx">
		<template v-slot:default>
			<view class="title">确认退出登录</view>
			<view class="desc">退出登录后，将无法使用相关权益，是否确认退出登录？</view>
		</template>
		<template v-slot:confirmButton>
			<view class="footerBtn">
				<view @click="close">取消</view>
				<view class="confirmClass" @click="logout">退出登录</view>
			</view>
		</template>
	</uv-modal>
	<uv-toast ref="uToast"></uv-toast>
</template>

<script setup>
	import { ref, nextTick } from 'vue'
	import { onLoad, onShow } from '@dcloudio/uni-app'
	import { useMainStore } from '@/store/store'
	const main = useMainStore()
	const uToast = ref()
	const modal = ref()
	const close = () => {
		modal.value.close()
		uni.navigateBack()
	}
	const logout = () => {
		
		uni.removeStorageSync('userinfo')
		uni.removeStorageSync('accessToken')
		main.SET_MEMBER({})
		main.SET_TOKEN('')
		uToast.value.show({
			message: '已退出',
			type: 'success',
		})
		modal.value.close()
		setTimeout(function () {
			uni.navigateBack()
			// uni.redirectTo({
			// 	url: '/pages/components/pages/login/login',
			// })
		}, 500)
	}
	onShow(() => {
		nextTick(() => {
			modal.value.open()
		})
	})
</script>

<style lang="scss" scoped>
	.title {
		display: flex;
		justify-content: center;
		font-size: 34rpx;
		font-weight: 700;
	}
	.desc{
		margin: 36rpx 0 0 0;
		line-height: 50rpx;
	}
	.footerBtn {
		display: flex;
		height: 90rpx;
		border-top: 2rpx solid #ccc;
		view {
			width: 50%;
			display: flex;
			justify-content: center;
			align-items: center;
			height: 100%;
			font-size: 34rpx;
		}
		.confirmClass {
			border-left: 2rpx solid #ccc;
			color: red;
			font-weight: bold;
		}
	}
</style>
